package com.iuie.ns.datum.dao.impl;

import java.util.List;

import org.hibernate.Query;
import org.springframework.stereotype.Repository;

import com.iuie.ns.datum.dao.IFileInfoDao;
import com.iuie.ns.datum.vo.FileInfoVO;
import com.iuie.ns.datum.vo.FileTagVO;
import com.iuie.ns.frame.persistence.dao.impl.GenericDaoImpl;
import com.iuie.ns.frame.web.dataset.vo.Page;

@Repository("fileInfoDao")
public class FileInfoDaoImpl extends GenericDaoImpl<FileInfoVO> implements IFileInfoDao {

//	private static final Logger logger = LoggerFactory.getLogger(FileInfoDaoImpl.class);
	
	@SuppressWarnings("unchecked")
	@Override
	public List<FileInfoVO> findByTag(Page page, FileTagVO fileTag) {
		Long tagId=fileTag.getTagId();
		String hql = "from FileInfoVO fileInfo where fileInfo.fileTag.tagId=:tagId";
		Query query = super.createQuery(hql);
		query.setParameter("tagId", tagId);
		List<FileInfoVO> list = query.list();
		return list;
	}

	@Override
	public void addFileInfo(FileInfoVO fileInfo, boolean commit) {
		super.save(fileInfo);
		if (commit) {
			getCurrentSession().flush();
		}
	}

	
}
